﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExBlogger.Domain;
using ExBlogger.Domain.Repositories;
using SharpArch.NHibernate;


namespace ExBlogger.Repository {
    public class BlogsRepository : NHibernateRepository<Blog>, IBlogsRepository {
        public IList<Blog> GetByUser(int userId) {
            var query = Session.QueryOver<Blog>().Where(x => x.Owner.Id == userId);
            return query.List<Blog>();
        }

        public IList<Blog> GetLatestBlogs(int count) {
            var query=Session.QueryOver<Blog>()
                .OrderBy(x => x.CreationDate).Desc
                .Take(count);
            return query.List<Blog>();
        }
    }
}
